package com.wordlearning.app.repository;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wordlearning.app.entity.Word;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Optional;

@Mapper
public interface WordRepository extends BaseMapper<Word> {

    public Optional<Word> findByContent(String content);
    
    public boolean existsByContent(String content);
    
    // 根据ID查询单词
    public Optional<Word> selectById(Long id);
    
    // 查询所有单词
    public List<Word> selectList();
    
    // 批量查询单词
    public List<Word> selectBatchIds(List<Long> ids);
    
    // 新增单词
    public int insert(Word word);
    
    // 更新单词
    public int updateById(Word word);
    
    // 删除单词
    public int deleteById(Long id);
    
    // 批量删除单词
    public int deleteBatchIds(List<Long> ids);
    
    // 根据部分内容模糊查询
    public List<Word> searchWords(@Param("keyword") String keyword, @Param("limit") int limit, @Param("offset") int offset);

}